<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Sales Order</title>
    </h:head>
      <f:view beforePhase="#{UserDisplayManagedBean.doDisplay}">
    <f:view beforePhase="#{SalesOrderManagedBean.initView2}">
    <h:body>
        <h:form prependId="false">
            <p:growl id="msgs" showDetail="true"/>
            <p:growl id="growl" showDetail="true"/>
            <p:growl id="notif" showDetail="true"/>
            <div id="top" class="top">
                <h:graphicImage value="/image/newHeader.jpg"/>
            </div>
            <div id="content">
                   <p:poll interval="5"   
                        actionListener="#{MessageManagedBean.checkNewMessage}" immediate="true" update="notif" />
               <table>
                            <tr>
                                <td>
                                    <p:toolbar style="font-size:12px;margin-top:0%;height:30px;width:200px"> 
                                        <p:toolbarGroup align="right" >
                                            <p:button title="Home" image="ui-icon-home" outcome="SalesDeptWorkspace"/>                                  
                                            <p:button title="Notes" image="ui-icon-note" outcome="tasks"/>                                    
                                            <p:button title="Mail" outcome="messages" image="ui-icon-mail-closed"/>                                    
                                            <p:button title="Edit Preferences" image="ui-icon-gear"/>                                   
                                            <p:button title="Help" image="ui-icon-help"/>
                                            <p:commandButton title="Log Out" immediate="true" type="submit" image="ui-icon-close" actionListener="#{UserManagedBean.doLogout}"/> 
                                        </p:toolbarGroup>
                                    </p:toolbar></td>
                                <td>
                                    <h:graphicImage value="8522350.png" style="width:35px;height:35px" />
                                    <h:outputText value="         "/>
                                    <h:outputText value="Sales Orders" style="font-family:Tahoma;font-size:20px;font-weight:bolder"/>
                                    <p:spacer width="100" height="10"/>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align:top">
                                    <p:menu style="width:200px;font-size: 12px;font-family: Tahoma;border-style: ridge">  
                                        <p:submenu label="Sales Force Automation" >  
                                            <p:menuitem value="Customers" url="http://localhost:8080/MerlionERP-war/CRM/customers.xhtml" ajax="false" icon="ui-icon ui-icon-person"/>  
                                            <p:menuitem value="Contacts" url="http://localhost:8080/MerlionERP-war/CRM/contacts.xhtml" ajax="false" icon="ui-icon ui-icon-person" />
                                            <p:menuitem value="Leads" url="http://localhost:8080/MerlionERP-war/CRM/salesLeads.xhtml" ajax="false" icon="ui-icon ui-icon-person" />
                                        </p:submenu>
                                        <p:submenu label="Sales Order Processing"> 
                                            <p:menuitem value="Pricebooks" url="http://localhost:8080/MerlionERP-war/CRM/pricebooks.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                            <p:menuitem value="Inquiries" url="http://localhost:8080/MerlionERP-war/CRM/salesInquiries.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                            <p:menuitem value="Quotations" url="http://localhost:8080/MerlionERP-war/CRM/quotations.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                            <p:menuitem value="Purchase Orders" url="http://localhost:8080/MerlionERP-war/CRM/purchaseOrders.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                            <p:menuitem value="Sales Orders" url="http://localhost:8080/MerlionERP-war/CRM/salesOrders.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                            <p:menuitem value="Delivery Orders" url="http://localhost:8080/MerlionERP-war/CRM/deliveryOrdersCRM.xhtml" ajax="false" icon="ui-icon ui-icon-document"/>
                                        </p:submenu>  
                                    </p:menu>
                                    <p:menu type="tiered" style="width:200px;font-family:Tahoma;font-size:12px">
                                        <p:submenu label="Create New" icon="ui-icon ui-icon-extlink">  
                                            <p:menuitem value="Customer" url="http://localhost:8080/MerlionERP-war/CRM/createNewCustomer.xhtml" />
                                            <p:menuitem value="Sales Lead" url="http://localhost:8080/MerlionERP-war/CRM/createNewSalesLead.xhtml" /> 
                                            <p:menuitem value="Contact" url="http://localhost:8080/MerlionERP-war/CRM/createNewContact.xhtml" />
                                            <p:menuitem value="Inquiry" url="http://localhost:8080/MerlionERP-war/CRM/addSalesInquiry.xhtml"/>
                                            <p:menuitem value="Quotation" url="http://localhost:8080/MerlionERP-war/CRM/addQuotation.xhtml"/>
                                            <p:menuitem value="Purchase Order" url="http://localhost:8080/MerlionERP-war/CRM/addPurchaseOrder.xhtml"/>
                                            <p:menuitem value="Sales Order" url="http://localhost:8080/MerlionERP-war/CRM/addSalesOrder.xhtml"/>
                                            <p:menuitem value="Delivery Order" url="http://localhost:8080/MerlionERP-war/CRM/addDeliveryOrder.xhtml"/>      
                                        </p:submenu>
                                    </p:menu>
                                    <p:calendar mode="inline" style="font-size:11px;font-family:Tahoma"/>
                                </td>
                                
                        <td style="vertical-align:top">
                            
                            <p:toolbar style="background-color:  #d9bb73;font-size: 70%;width:99.5%"> 

                                <p:toolbarGroup align="left">  
                                    <p:button value="New Sales Order" outcome="addSalesOrder" image="ui-icon-plus"/>
                                    <p:commandButton value="Delete" title="Delete" image="ui-icon ui-icon-trash" oncomplete="deleteDialog.show()"/>                                   
                                    <p:commandButton value="Request for Invoice" image="ui-icon ui-icon-script" oncomplete="invoiceDialog.show()"/>
                                </p:toolbarGroup>  

                            </p:toolbar> 

                            <p:dataTable id="panel" 
                                         var="salesOrders" value="#{SalesOrderManagedBean.salesOrderList}"                       
                                         paginator="true" rows="5"  
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                         rowEditListener="#{SalesOrderManagedBean.onEditRow}"
                                         rowsPerPageTemplate="5,10,15"  style="font-size:60%;width:100%"
                                         selection="#{SalesOrderManagedBean.selectedSalesOrders}"
                                         emptyMessage="No data found with given criteria" widgetVar="salesOrderTable">  
                                
                               <f:facet name="header">                           
                                    <p:outputPanel style="text-align:right"  >
                                        <h:outputText value="Search all fields:" style="margin-left:840px" />  
                                        <p:inputText id="globalFilter" onkeyup="salesOrderTable.filter()" style="right:-100px;width:150px" />  
                                    </p:outputPanel>
                                </f:facet> 
                                
                                <p:column selectionMode="multiple" /> <!--style="border-left-color:transparent;border-right-color:transparent"/>-->
  
                                
                                <p:column headerText="View" style="width:20px;border-right-color:transparent">  
                                    <p:rowToggler />  
                                </p:column>
           
                                
                                <p:column headerText="Edit" style="width:20px;border-left-color:transparent;border-right-color:transparent">    
                                    <p:rowEditor rendered="#{!salesOrders.completed}"/>
                                </p:column>
                                
                                <p:column headerText="Del." style="width: 16px;border-left-color:transparent">
                                    <!--DELETE-->
                                    <p:commandButton title="Delete" image="ui-icon ui-icon-trash" ajax="true" immediate="true"
                                                     update="panel" oncomplete="sodialog.show()">
                                        <f:setPropertyActionListener target="#{SalesOrderManagedBean.selectedSalesOrder}"
                                                                     value="#{salesOrders}"/>
                                    </p:commandButton>
                                </p:column>
                                

 
                                <!--SALES ORDER ID-->
                                <p:column sortBy="#{salesOrders.id}" filterBy="#{salesOrders.id}" 
                                          filterMatchMode="contains" filterStyle="width:50px"> 
                                          <!--style="border-left-color:transparent;border-right-color:transparent">-->
                                    <f:facet name="header">
                                        <h:outputText value="ID"/>
                                    </f:facet>
                                    <h:outputText value="#{salesOrders.id}"/>
                                </p:column>
                                
                                <!--DATE ISSUED-->
                                 <p:column headerText="Date Issued" sortBy="#{salesOrders.dateIssued}" 
                                           filterBy="#{salesOrders.dateIssued}" filterMatchMode="contains">
                 
                                            <h:outputText value="#{salesOrders.dateIssued}" />  
                        
                                </p:column>   
                                

                                <!--CLIENT NAME-->
                                <p:column headerText="Client Name" sortBy="#{salesOrders.clientName}" 
                                          filterBy="#{salesOrders.clientName}" filterMatchMode="contains">
                                          <!--style="border-left-color:transparent;border-right-color:transparent"-->
                                            <h:outputText value="#{salesOrders.clientName}"/>
                                </p:column>
                                
                                 <!--STATUS-->
                                <p:column headerText="Status" sortBy="#{salesOrders.status}" 
                                          filterBy="#{salesOrders.status}" filterMatchMode="contains"
                                          filterStyle="width:70px"> 
                                    <!-- style="border-left-color:transparent;border-right-color:transparent">-->
                                    <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{salesOrders.status}"/>
                                    </f:facet>
                                    <f:facet name="input">            
                                        <h:selectOneMenu value="#{salesOrders.status}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/> 
                                            <f:selectItem itemLabel="Approved" itemValue="Approved"/>
                                            <f:selectItem itemLabel="Rejected" itemValue="Rejected"/>
                                            <f:selectItem itemLabel="Voided" itemValue="Voided"/>
                                            <f:selectItem itemLabel="On Hold" itemValue="On Hold"/> 
      
                                            <f:selectItem itemLabel="Completed" itemValue="Completed"/> 
                                        </h:selectOneMenu>
                                    </f:facet>
                                    </p:cellEditor>
                                </p:column>
                                 
                                 <p:column headerText="Credit Check" sortBy="#{salesOrders.creditCheckStatus}" 
                                           filterBy="#{salesOrders.creditCheckStatus}" filterMatchMode="contains"
                                          filterStyle="width:70px"> <!-- style="border-left-color:transparent;border-right-color:transparent"-->
                                    <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{salesOrders.creditCheckStatus}"/>
                                    </f:facet>
                                    <f:facet name="input">            
                                        <h:selectOneMenu value="#{salesOrders.creditCheckStatus}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/>
                                            <f:selectItem itemLabel="Approved" itemValue="Approved"/>
                                            <f:selectItem itemLabel="Rejected" itemValue="Rejected"/>
                                  
                                        </h:selectOneMenu>
                                    </f:facet>
                                    </p:cellEditor>
                                </p:column>
                                 
                                 <p:column headerText="ATP Check" sortBy="#{salesOrders.ATPCheckStatus}" 
                                           filterBy="#{salesOrders.ATPCheckStatus}" filterMatchMode="contains"
                                          filterStyle="width:70px"> 
                                     <!-- style="border-left-color:transparent;border-right-color:transparent">-->
                                    <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{salesOrders.ATPCheckStatus}"/>
                                    </f:facet>
                                    <f:facet name="input">            
                                        <h:selectOneMenu value="#{salesOrders.ATPCheckStatus}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/>
                                            <f:selectItem itemLabel="Available" itemValue="Available"/>
                                            <f:selectItem itemLabel="Not Available" itemValue="Not Available"/>
                                          
                                        </h:selectOneMenu>
                                    </f:facet>
                                    </p:cellEditor>
                                </p:column>
                                 
                                 <!--Total Price-->
                                 <p:column headerText="Total Price" sortBy="#{salesOrders.totalPrice}" 
                                           filterBy="#{salesOrders.totalPrice}" filterMatchMode="contains"
                                           filterStyle="width:60px">
                                     <!--style="border-left-color:transparent;border-right-color:transparent">-->

                                     <h:outputText value="#{salesOrders.totalPrice}"/>
                                 </p:column>
                                 
                                 <p:column headerText="Purchase Order ID" sortBy="#{salesOrders.poID}" 
                                           filterBy="#{salesOrders.poID}" filterMatchMode="contains"
                                           filterStyle="width:50px" style="width:60px">
                                     <!--style="border-left-color:transparent;border-right-color:transparent">  -->                                   
                                             <h:outputText value="#{salesOrders.poID}" />   
                                 </p:column>   
                               
                                 <p:column style="width:20px">  
                                     <p:commandLink rendered="#{!salesOrders.completed}" update="display1" oncomplete="soDialog.show()" title="Edit Details" >
                                         <p:graphicImage value="about_icon.png" style="width:20px;height:20px"  />
                                         <f:setPropertyActionListener value="#{salesOrders}" target="#{SalesOrderManagedBean.selectedViewSalesOrder}" />  
                                         <f:setPropertyActionListener value="#{true}" target="#{SalesOrderManagedBean.editMode}" />  
                                     </p:commandLink>                                                                
                                 </p:column>
                                 
                                  <p:column>
                                     <p:commandButton image="ui-icon ui-icon-print" ajax="true" immediate="true"
                                                       actionListener="#{SalesOrderManagedBean.generateSalesOrderReport}">
                                         <f:setPropertyActionListener target="#{SalesOrderManagedBean.selectedPrintSalesOrder}"        
                                                                      value="#{salesOrders}"/>
                                     </p:commandButton>
                                 </p:column>
                                 
                                 <p:rowExpansion>  
                                    <h:panelGrid id="display" columns="6" cellpadding="3"
                                                 style="font-family:Tahoma; font-size:10px;border-color:transparent;column-rule-style:hidden">
                                                 
                                        <h:outputText value="Sales Order Id" />  
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.id}" />
                                        
                                        <h:outputText value="Sales Order Name" />  
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.documentName}" />
                                        
                                        <h:outputText value="Date Issued" />  
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.dateIssued}" />
                                        
                                         <h:outputText value="Date Due" />  
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.dueDate}" />  
                                        
                                        <h:outputText value="Client Id" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.clientId}" /> 
                                              
                                        <h:outputText value="Client Name" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.clientName}" />
                                        
                                        <h:outputText value="Contact Id" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.contactId}" /> 
                                              
                                        <h:outputText value="Contact Name" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.contactName}" />
                                        
                                        <h:outputText value="Shipping Location" />
                                        <h:outputText value=""/>
                                        <h:outputText value="" />
                                        
                                        <h:outputText value="Billing Location" />
                                        <h:outputText value=""/>
                                        <h:outputText value="" />
                                        
                                        <h:outputText value="Street Address" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingStreet}" />
                                        
                                        <h:outputText value="Street Address" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.billingStreet}" />
                                        
                                        <h:outputText value="City" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingCity}" />
                                        
                                        <h:outputText value="City" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.billingCity}" />
                                        
                                        <h:outputText value="State" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingState}" />
                                        
                                        <h:outputText value="State" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.billingState}" />
                                        
                                        <h:outputText value="Postal Code" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingCode}" />
                                        
                                        <h:outputText value="Postal Code" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.billingCode}" />
                                        
                                         <h:outputText value="Country" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingCountry}" />
                                        
                                        <h:outputText value="Country" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.billingCountry}" />
                                        
                                        <h:outputText value="Shipping Rule" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingRule}" />
                                        
                                        <h:outputText value="Shipping Method" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.shippingMethod}" />
                                        
                                         <h:outputText value="Freight Cost Rule" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.freightCostRule}" />
                                        
                                        <h:outputText value="Payment Method" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.paymentMethod}" />
                                        
                                          <h:outputText value="Invoice Rule" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.invoiceRule}" />
                                        
                                        <h:outputText value="Currency" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.currency}" />
                                        
                                           
                                        <h:outputText value="Lead Time" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.leadTime}" />
                                        
                                        <h:outputText value="Confirmed Lead Time" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.confirmedLeadTime}" />
                                     
                                        <h:outputText value="Status" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.status}" />
                                        
                                        <h:outputText value="ATP Check" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.ATPCheckStatus}" />
                                        
                                        <h:outputText value="Credit Check" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.creditCheckStatus}" />
                                     
                                        
                                        <h:outputText value="Description" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.description}" />
                                        
                                         <h:outputText value="Total Price" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.totalPrice}" />
                                        
                                         <h:outputText value="Purchase Order ID" />
                                        <h:outputText value=":"/>
                                        <h:outputText value="#{salesOrders.poID}" />

                                    </h:panelGrid>  
                                </p:rowExpansion> 
                            </p:dataTable>  
                   
                            
                              <p:ajaxStatus style="width:16px;height:16px;">  
                                    <f:facet name="start">  
                                        <h:graphicImage value="25(2).gif" />  
                                    </f:facet>  

                                    <f:facet name="complete">  
                                        <h:outputText value="" />  
                                    </f:facet>  
                              </p:ajaxStatus> 
                            
                            <p:dialog header="Sales Order Detail" modal="true" widgetVar="soDialog" resizable="true"  
                                      width="800" >  
                                <p:panel  id="display1" style="border-style: hidden;font-family:Tahoma;font-size:11px">"
                                <center>
                                <!--<h:panelGrid id="display1" columns="6" cellpadding="1" cellspacing="1" style="font-family:Tahoma;font-size:11px" >-->  
                                <table cellspacing="1" cellpadding="1" width="100%">
                                    <tr>
                                    <td><h:outputText value="ID" style="font-weight:bold"/></td> 
                                    <td width="2%"><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.id}" />  
                                        </td>
                                        
                                    <td><h:outputText value="Sales Order Name" style="font-weight:bold"/></td> 
                                    <td width="2%"><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.documentName}"
                                                      style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.documentName}" 
                                                     rendered="#{SalesOrderManagedBean.editMode}" required="true"/>
                                    </h:panelGroup></td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Date Issued" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.dateIssued}"/>
                                    </td>
                                            
                                    <td><h:outputText value="Date Due" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.dueDate}"
                                                      style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>
                                        <p:calendar value="#{SalesOrderManagedBean.selectedViewSalesOrder.dueDate}"
                                                    rendered="#{SalesOrderManagedBean.editMode}" required="true"/>
                                    </h:panelGroup></td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Client ID" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>                                  
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.clientId}" /></td>  

                                    <td><h:outputText value="Client Name" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.clientName}" />  </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Contact ID - Name" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>                                  
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.contactId} - #{SalesOrderManagedBean.selectedViewSalesOrder.contactName}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <h:selectOneMenu value="#{SalesOrderManagedBean.selectedViewSalesOrder.contactId}"
                                                         rendered="#{SalesOrderManagedBean.editMode}">  

                                            <f:selectItem itemLabel="Select Contact [ID - Name]" itemValue=""/>
                                            <f:selectItems value="#{SalesOrderManagedBean.selectedContactList}" var="contacts"
                                                           itemLabel ="#{contacts.id} - #{contacts.firstName} #{contacts.lastName}" itemValue="#{contacts.id}"/>    
                                        </h:selectOneMenu>
                                  
                                    </h:panelGroup></td>
                                    </tr>
           
                                    <tr>
                                    <td><h:outputText value="Shipping Street" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingStreet}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingStreet}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup>  </td>                                   
                                    
                                    
                                    <td><h:outputText value="Billing Street" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingStreet}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingStreet}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup></td>
                                    </tr>
                                    
                                    <tr>
                                    <td> <h:outputText value="Shipping State" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingState}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingState}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup></td>  
                                    
                                 
                                    <td><h:outputText value="Billing State" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingState}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingState}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup>
                                    </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Shipping City" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCity}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCity}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup></td>  
                            
                                    <td><h:outputText value="Billing City" style="font-weight:bold"/></td> 
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCity}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCity}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup>  </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Shipping Code" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCode}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCode}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup>  </td>
                     
                            
                                    <td><h:outputText value="Billing Code" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCode}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCode}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup>  </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Shipping Country" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCountry}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingCountry}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup></td>  
                                  
                                    <td><h:outputText value="Billing Country" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCountry}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.billingCountry}" rendered="#{SalesOrderManagedBean.editMode}" required="true" label="Company Name"/>  
                                    </h:panelGroup> </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Shipping Method" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingMethod}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <h:selectOneMenu value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingMethod}" 
                                                         rendered="#{SalesOrderManagedBean.editMode}" >
                                            <f:selectItem itemLabel="Land" itemValue="Land"/>
                                            <f:selectItem itemLabel="Air" itemValue="Air"/>
                                            <f:selectItem itemLabel="Sea" itemValue="Sea"/>
                                        </h:selectOneMenu>
                    
                                    </h:panelGroup>  </td>
                               
                                    <td><h:outputText value="Shipping Rule" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingRule}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <h:selectOneMenu value="#{SalesOrderManagedBean.selectedViewSalesOrder.shippingRule}"
                                                         rendered="#{SalesOrderManagedBean.editMode}">  
                                        <f:selectItem itemLabel="Availability" itemValue="Availability"/>
                                      
                                        </h:selectOneMenu>
                                    </h:panelGroup></td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Freight Cost Rule" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="Freight Cost Included."/>  </td>
   

                                    <td><h:outputText value="Payment Method" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.paymentMethod}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <h:selectOneMenu  value="#{SalesOrderManagedBean.selectedViewSalesOrder.paymentMethod}" 
                                                           rendered="#{SalesOrderManagedBean.editMode}" >
                                        <f:selectItem itemValue="On Credit" itemLabel="On Credit"/>   
                                        <!--<f:selectItem itemValue="Credit Card" itemLabel="Credit Card"/>-->
                                        <f:selectItem itemValue="Cash" itemLabel="Cash"/>
                                        <!--<f:selectItem itemValue="Check" itemLabel="Check"/>-->
                                        </h:selectOneMenu>
                                    </h:panelGroup>  </td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Invoice Rule" style="font-weight:bold"/> </td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>  
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.invoiceRule}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>  
                                        <h:selectOneMenu value="#{SalesOrderManagedBean.selectedViewSalesOrder.invoiceRule}"
                                                         rendered="#{SalesOrderManagedBean.editMode}">  
                                        <f:selectItem itemLabel="After Delivery" itemValue="After Delivery"/>
                                    </h:selectOneMenu>
                                    </h:panelGroup></td>
                                    
                                    <td><h:outputText value="Currency" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="SGD"/></td>
                                    </tr>
                                    <tr>
                                    <td><h:outputText value=""/></td>
                                    <td><h:outputText value=""/></td>
                                    <td><h:outputText value=""/></td></tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Status" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.status}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>
                                        <h:selectOneMenu  value="#{SalesOrderManagedBean.selectedViewSalesOrder.status}" rendered="#{SalesOrderManagedBean.editMode}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/> 
                                            <f:selectItem itemLabel="Approved" itemValue="Approved"/>
                                            <f:selectItem itemLabel="Rejected" itemValue="Rejected"/>
                                            <f:selectItem itemLabel="Voided" itemValue="Voided"/>
                                            <f:selectItem itemLabel="On Hold" itemValue="On Hold"/> 
       
                                            <f:selectItem itemLabel="Completed" itemValue="Completed"/> 
        
                                        </h:selectOneMenu>
                                    </h:panelGroup></td>
                                    
                                    <td><h:outputText value="ATP Check Status" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.ATPCheckStatus}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>
                                        <h:selectOneMenu  value="#{SalesOrderManagedBean.selectedViewSalesOrder.ATPCheckStatus}" rendered="#{SalesOrderManagedBean.editMode}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/>
                                            <f:selectItem itemLabel="Available" itemValue="Available"/>
                                            <f:selectItem itemLabel="Not Available" itemValue="Not Available"/>
                                                                                       
                                        </h:selectOneMenu>
                                    </h:panelGroup></td></tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Credit Check Status" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.creditCheckStatus}" style="font-weight:bold" rendered="#{!SalesOrderManagedBean.editMode}"/>
                                        <h:selectOneMenu  value="#{SalesOrderManagedBean.selectedViewSalesOrder.creditCheckStatus}" rendered="#{SalesOrderManagedBean.editMode}">
                                            <f:selectItem itemLabel="In Progress" itemValue="In Progress"/>
                                            <f:selectItem itemLabel="Approved" itemValue="Approved"/>
                                            <f:selectItem itemLabel="Rejected" itemValue="Rejected"/>
                                                                           
                                        </h:selectOneMenu>
                                    </h:panelGroup></td>
                                    
                                    <td><h:outputText value="Total Price" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.totalPrice}"/></td>
                                    </tr>
                                    
                                     <tr>
                                    <td><h:outputText value="Lead Time" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.leadTime}"/>
             
                                    </h:panelGroup></td>
                                    
                                    <td><h:outputText value="Confirmed Lead Time" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.confirmedLeadTime}"/></td>
                                    </tr>
                                    
                                    <tr>
                                    <td><h:outputText value="Purchase Order ID" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.poID}"/></td>
                                    
                                    <td><h:outputText value="Description" style="font-weight:bold"/></td>
                                    <td><h:outputText value=":"/></td>
                                    <td><h:panelGroup>
                                        <h:outputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.description}"
                                                  rendered="#{!SalesOrderManagedBean.editMode}"/>
                                        <p:inputText value="#{SalesOrderManagedBean.selectedViewSalesOrder.description}"
                                                 rendered="#{SalesOrderManagedBean.editMode}"/>
                                    </h:panelGroup></td>
                                    </tr>
                                    
                                    <tr><td colspan="6" align="left">
                                    <p:dataTable id="childPanel" value="#{SalesOrderManagedBean.selectedProductList}"
                                                 rowEditListener="#{SalesOrderManagedBean.onEditLineEntry}"
                                                 var="lineEntry" style="width:100%"  >
                                        <p:column headerText="Product ID">
                                            <h:outputText value ="#{lineEntry.itemId}"/>
                                        </p:column>

                                        <p:column headerText="Product Name">
                                            <h:outputText value="#{lineEntry.itemName}"/>
                                        </p:column>

                                        <p:column style="width:60px" headerText="Quantity">
                                            <h:outputText value="#{lineEntry.quantity}"/>
                                        </p:column>

                            
                                        <p:column style="width:60px" headerText="Price">
                                            <h:outputText value="#{lineEntry.price}"/>
                                        </p:column>
                                        
                                        <p:column headerText="Total Price">
                                            <h:outputText value="#{lineEntry.totalPrice}"/>
                                        </p:column>
                                        
                                        <p:column style="width:60px" headerText="Lead Time">
                                            <p:cellEditor>
                                                <f:facet name="output">
                                                    <h:outputText value="#{lineEntry.indicativeLeadTime}"/>
                                                </f:facet>
                                                <f:facet name="input">
                                                    <p:inputText value="#{lineEntry.indicativeLeadTime}" style="width:100%"/>
                                                </f:facet>
                                            </p:cellEditor>
                                        </p:column>

                                            <p:column style="width:60px" headerText="Amount Shipped">
                                                <p:cellEditor>
                                                    <f:facet name="output">
                                                        <h:outputText value="#{lineEntry.amountShipped}"/>
                                                    </f:facet>
                                                    <f:facet name="input">
                                                        <p:inputText value="#{lineEntry.amountShipped}" style="width:100%"/>
                                                    </f:facet>
                                                </p:cellEditor>
                                            </p:column>

                                            <p:column style="width:60px" headerText="Amount Invoiced">
                                                <p:cellEditor>
                                                    <f:facet name="output">
                                                        <h:outputText value="#{lineEntry.amountInvoiced}"/>
                                                    </f:facet>
                                                    <f:facet name="input">
                                                        <p:inputText value="#{lineEntry.amountInvoiced}" style="width:100%"/>
                                                    </f:facet>
                                                </p:cellEditor>
                                            </p:column>

                                        <p:column style="width:20px; border-left-style: transparent">    
                                            <p:rowEditor/>
                                        </p:column>
                                        
                                    </p:dataTable></td></tr>
                                </table>
                                    <p:outputPanel rendered="#{SalesOrderManagedBean.editMode}" layout="block" style="text-align:right">  
                                        <p:commandButton value="Save" update="panel msgs" actionListener="#{SalesOrderManagedBean.save}"   
                                                         oncomplete="soDialog.hide()" image="ui-icon ui-icon-check" />  
                                        <p:commandButton value="Cancel" onclick="soDialog.hide()" type="button" image="ui-icon ui-icon-close"/>  
                                    </p:outputPanel> 
                                </center>
                                </p:panel>  
                         
                            </p:dialog>
                          
                            <!--DIALOG FOR DELETING A  SINGLE ROW-->
                            <p:confirmDialog message="Are you sure you want to delete this sales order?"  
                                             showEffect="blind" hideEffect="blind" modal="true"  
                                             header="Delete Sales Order" severity="alert" widgetVar="sodialog">  
                                <center>
                                <p:commandButton value="Yes" update="panel" ajax="true" immediate="true" oncomplete="sodialog.hide()"  
                                                 actionListener="#{SalesOrderManagedBean.delete}" />  
                                <p:commandButton value="No" onclick="sodialog.hide()" type="button" />   
                                </center>
                                
                            </p:confirmDialog>  

                            
                            <!--DIALOG FOR DELETING MULTIPLE ROW OF SALES ORDERS-->
                            <p:dialog header="Delete Selected Records" modal="true" widgetVar="deleteDialog">

                                <h:outputText value="You are about to permanently delete records." /><br /><br />
                                <h:outputText value="Are you sure you want to continue?" /><br /><br/>
                                
                                <center>
                                <p:commandButton value="Yes" ajax="true" immediate="true" update="panel" 
                                                 oncomplete="deleteDialog.hide()" actionListener="#{SalesOrderManagedBean.deleteSalesOrders}" />
                                <p:commandButton value="No" oncomplete="deleteDialog.hide()" action="#{SalesOrderManagedBean.cancelDelete()}" /> 
                                
                                </center>
                            </p:dialog>
                            
                            <p:dialog header="Request For Invoice" modal="true" widgetVar="invoiceDialog">

                                <h:outputText value="Request for invoice for the following sales orders." /><br /><br />
                                <h:outputText value="Are you sure you want to continue?" /><br /><br/>
                                
                                <center>
                                <p:commandButton value="Yes" ajax="true" immediate="true" update="panel" 
                                                 oncomplete="invoiceDialog.hide()" actionListener="#{SalesOrderManagedBean.requestForInvoice}" />
                                <p:commandButton value="No" oncomplete="invoiceDialog.hide()"/> 
                                
                                </center>
                            </p:dialog>

                      
                        </td>
                    </tr>
                </table>
  
            </div>
            <div id="bottom" class="bottom">
                <h:graphicImage value="/image/merlionfooter.jpg"/>
            </div>
        </h:form>
    </h:body>
    </f:view>
      </f:view>
  </html>